package common

import (
	"context"
	"sale-admin/internal/app/grpc/client"
	"sale-admin/internal/app/grpc/protoc/system_admin"

	"192.168.1.75/go-pkg/errorx"
)

// GetUsernameMap 获取用户名称
func GetUsernameMap(ctx context.Context, userIDs []string) (usernameMap map[string]string, err error) {
	cli, err := client.GetSystemAdminClient()
	if err != nil {
		return nil, errorx.New("获取用户名称失败-cli", -1)
	}
	rsp, err := cli.UserName(ctx, &system_admin.UserNameReq{
		UserIds: userIDs,
	})
	if err != nil {
		return nil, errorx.New("获取用户名称失败", -1)
	}
	return rsp.UserNameMap, nil
}
